package com.example.service;

import com.example.entity.UserProgress;
import com.example.entity.VideoCategory;
import com.example.mapper.VideoCategoryMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*视频分类业务处理
 */
@Service
public class VideoCategoryService {

    @Resource
    private VideoCategoryMapper videoCategoryMapper;

    public void add(VideoCategory videoCategory) {
        videoCategoryMapper.insert(videoCategory);
    }

    public void deleteById(Integer id) {
        videoCategoryMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(VideoCategory videoCategory) {
        videoCategoryMapper.updateById(videoCategory);
    }

    public VideoCategory selectById(Integer id) {
        return videoCategoryMapper.selectById(id);
    }

    public List<VideoCategory> selectAll(VideoCategory videoCategory) {
        return videoCategoryMapper.selectAll(videoCategory);
    }

    public PageInfo<VideoCategory> selectPage(VideoCategory videoCategory, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<VideoCategory> videoCategoryList = videoCategoryMapper.selectAll(videoCategory);
        return PageInfo.of(videoCategoryList);
    }
}
